hvm: Fix getvcpucontext to return the correct CR3 value.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Tue, 20 Feb 2007 23:54:42 +0000 (23:54 +0000)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Tue, 20 Feb 2007 23:54:42 +0000 (23:54 +0000)
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/domctl.c
xen/arch/x86/hvm/vmx/vmx.c

index 69e2259d7f26e39fcb4bc55c67bc0f3980b1ce9f..d8f78c626227f2c10d93058ceab18405b7ac034f 100644 (file)
@@ -441,6 +441,10 @@ void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c)
         XLAT_vcpu_guest_context(c.cmp, &v->arch.guest_context);
 #endif
 
+    c(flags &= ~(VGCF_i387_valid|VGCF_in_kernel));
+    if ( test_bit(_VCPUF_fpu_initialised, &v->vcpu_flags) )
+        c(flags |= VGCF_i387_valid);
+
     if ( is_hvm_vcpu(v) )
     {
         if ( !IS_COMPAT(v->domain) )
@@ -464,24 +468,22 @@ void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c)
         /* IOPL privileges are virtualised: merge back into returned eflags. */
         BUG_ON((c(user_regs.eflags) & EF_IOPL) != 0);
         c(user_regs.eflags |= v->arch.iopl << 12);
-    }
 
-    c(flags &= ~(VGCF_i387_valid|VGCF_in_kernel));
-    if ( test_bit(_VCPUF_fpu_initialised, &v->vcpu_flags) )
-        c(flags |= VGCF_i387_valid);
-    if ( guest_kernel_mode(v, &v->arch.guest_context.user_regs) )
-        c(flags |= VGCF_in_kernel);
-
-    if ( !IS_COMPAT(v->domain) )
-        c.nat->ctrlreg[3] = xen_pfn_to_cr3(pagetable_get_pfn(v->arch.guest_table));
+        if ( !IS_COMPAT(v->domain) )
+            c.nat->ctrlreg[3] = xen_pfn_to_cr3(
+                pagetable_get_pfn(v->arch.guest_table));
 #ifdef CONFIG_COMPAT
-    else
-    {
-        l4_pgentry_t *l4e = __va(pagetable_get_paddr(v->arch.guest_table));
-        c.cmp->ctrlreg[3] = compat_pfn_to_cr3(l4e_get_pfn(*l4e));
-    }
+        else
+        {
+            l4_pgentry_t *l4e = __va(pagetable_get_paddr(v->arch.guest_table));
+            c.cmp->ctrlreg[3] = compat_pfn_to_cr3(l4e_get_pfn(*l4e));
+        }
 #endif
 
+        if ( guest_kernel_mode(v, &v->arch.guest_context.user_regs) )
+            c(flags |= VGCF_in_kernel);
+    }
+
     c(vm_assist = v->domain->vm_assist);
 #undef c
 }
index 5613cdb333ab418c586f7ea62e46882edf28a5f5..0301781c18e3478cd13f90ab4220861d198bd193 100644 (file)
@@ -696,7 +696,7 @@ static void vmx_store_cpu_guest_regs(
     {
         crs[0] = v->arch.hvm_vmx.cpu_shadow_cr0;
         crs[2] = v->arch.hvm_vmx.cpu_cr2;
-        crs[3] = __vmread(GUEST_CR3);
+        crs[3] = v->arch.hvm_vmx.cpu_cr3;
         crs[4] = v->arch.hvm_vmx.cpu_shadow_cr4;
     }